package com.ruoyi.informfrontend.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.informfrontend.domain.ArticleComment;
import com.ruoyi.informfrontend.mapper.ArticleCommentMapper;
import com.ruoyi.informfrontend.mapper.SysUserMapper;
import com.ruoyi.informfrontend.service.IArticleCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 资讯评论Service业务层处理
 *
 * @author ruoyi
 * @date 2023-06-13
 */
@Service
public class ArticleCommentServiceImpl implements IArticleCommentService {
    @Autowired
    private ArticleCommentMapper articleCommentMapper;

    @Autowired
    private SysUserMapper userMapper;

    /**
     * 查询资讯评论
     *
     * @param id 资讯评论主键
     * @return 资讯评论
     */
    @Override
    public ArticleComment selectArticleCommentById(Long id) {
        return articleCommentMapper.selectArticleCommentById(id);
    }

    /**
     * 查询资讯评论列表
     *
     * @param articleComment 资讯评论
     * @return 资讯评论
     */
    @Override
    public List<ArticleComment> selectArticleCommentList(ArticleComment articleComment) {
        return articleCommentMapper.selectArticleCommentList(articleComment);
    }

    /**
     * 新增资讯评论
     *
     * @param articleComment 资讯评论
     * @return 结果
     */
    @Override
    public int insertArticleComment(ArticleComment articleComment) {
        articleComment.setUserId(SecurityUtils.getUserId());
        articleComment.setCreateTime(DateUtils.getNowDate());
        return articleCommentMapper.insertArticleComment(articleComment);
    }

    /**
     * 修改资讯评论
     *
     * @param articleComment 资讯评论
     * @return 结果
     */
    @Override
    public int updateArticleComment(ArticleComment articleComment) {
        articleComment.setUpdateTime(DateUtils.getNowDate());
        return articleCommentMapper.updateArticleComment(articleComment);
    }

    /**
     * 批量删除资讯评论
     *
     * @param ids 需要删除的资讯评论主键
     * @return 结果
     */
    @Override
    public int deleteArticleCommentByIds(Long[] ids) {
        return articleCommentMapper.deleteArticleCommentByIds(ids);
    }

    /**
     * 删除资讯评论信息
     *
     * @param id 资讯评论主键
     * @return 结果
     */
    @Override
    public int deleteArticleCommentById(Long id) {
        return articleCommentMapper.deleteArticleCommentById(id);
    }
}
